package com.hfi.restful.dto;

import com.fasterxml.jackson.annotation.JsonView;
import com.hfi.restful.response.Response;
import com.hfi.restful.validator.MyConstraint;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Max;
import javax.validation.constraints.Past;
import java.util.Date;

/**
 * @author ChangLiang
 * @date 2019/7/29
 */
@Data
public class User {

    public interface UserSimpleView {}

    public interface UserDetailView extends UserSimpleView {}

    @ApiModelProperty("用户id")
    @Max(1000)
    @JsonView({UserSimpleView.class, Response.ResponseView.class})
    private Integer id;

    @ApiModelProperty("用户名")
    @MyConstraint
    @JsonView({UserSimpleView.class, Response.ResponseView.class})
    private String username;

    @ApiModelProperty("密码")
    @NotBlank(message = "密码不能为空")
    @JsonView({UserDetailView.class, Response.ResponseDetailView.class})
    private String password;

    @ApiModelProperty("生日")
    @JsonView({UserSimpleView.class, Response.ResponseView.class})
    @Past(message = "生日必须是一个过去的日期")
    private Date birthday;
}